package org.cdc.mre.manager;

import org.cdc.Main;

import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class IndexManager {
    public static Map<String,File> makeIndex(File path){
        if (!path.isDirectory()) return null;
        List<File> index = new ArrayList<>();
        Map<String,File> indexMap = new HashMap<>();
        for (File fl : makeIndex(path,index)){
            indexMap.put(fl.getName(),fl);
        }
        return indexMap;
    }
    public static List<File> makeIndex(File path,List<File> index){
        for (File fl:path.listFiles()){
            if (fl.isDirectory()){
                makeIndex(fl,index);
            } else {
                index.add(fl);
            }
        }
        return index;
    }
}
